# -*- coding: utf-8 -*-
"""
Created on Wed Mar 22 12:21:20 2023

@author: skunk69
"""
from pathlib import Path
from datetime import datetime

def out_path_handle(in_path, path_str="", file_suffix=""):
	"""
	in_path：输入文件路径
    path_str：文件路径构造字符
    file_suffix：输出文件后缀
	"""
	if path_str == "":
		path_str = str(datetime.now()).replace(":", "").replace(" ", "_").replace("-", "").replace(".", "_")[
		           :22]
	elif path_str[-1] == "_":
		path_str = path_str + str(datetime.now()).replace(":", "").replace(" ", "_").replace("-", "").replace(
			".", "_")[:22]
	if file_suffix == "":
		file_suffix = Path(in_path).suffix

	if Path(in_path).exists():
		if Path(in_path).is_dir():
			path = Path(in_path).joinpath(path_str + file_suffix)
		elif Path(in_path).is_file():
			path = Path(in_path).parent.joinpath(Path(in_path).stem + "_" + path_str + file_suffix)
		return path

	else:
		print("输入有误！")
		return []

if __name__ == '__main__':
    input_path = Path.cwd()
    out_path = out_path_handle(input_path,"",".py")
    print(out_path)
